public class ReverseLinkedList {
    public ListNode reverseList(ListNode head) {
        ListNode virtualNode = new ListNode();
        // 头插法逆序
        while(head != null) {
            ListNode next = head.next;
            head.next = virtualNode.next;
            virtualNode.next = head;
            head = next;
        }
        return virtualNode.next;
    }
}
